package com.microservice.microservicemovie;

import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 如果想要这个放在 application 扫描包之内，且生效的话，需要添加这个注解，并且在 MicroserviceMovieApplication 上面配置不扫苗
 */
@Configuration
@ExcludeFromComponentScan
public class TestConfiguration {

    @Autowired
    IClientConfig config;

    /**
     *  定义自定义的 负载均衡规则，默认为 RibbonClientConfiguration.ribbonRule
     * @param config
     * @return
     */
    @Bean
    public IRule ribbonRule(IClientConfig config) {
        return new RandomRule();
    }
}